<?php
$op=$_GET['op'];
$channel_id = $_REQUEST['channel_id'];
$activity = '2';
if($channel_id){
    $sql = "select * from tttj.activity_log where channel = $channel_id and activity = $activity";
    $re = getonerecord($sql);
    if($re){
        $sql = "update tttj.activity_log set click_num=click_num+1 where id=".$re['id'];
    }else{
        $sql = "insert into tttj.activity_log (click_num,channel,activity) VALUES (1,$channel_id,$activity)";
    }
    exec_db($sql);
}
$tpl->assign('channel',$channel_id);

if($op == 'dolog'){
    $test = $_REQUEST['test_id'];
    $type = $_REQUEST['type'];
    $activity = '2';
    $sql = "select * from tttj.activity_log where channel = $test and activity = $activity";
    $re = getonerecord($sql);
    if($re){
        if($type == '1'){
            $sql = "update tttj.activity_log set android=android+1 where id=".$re['id'];
        }else{
            $sql = "update tttj.activity_log set ios=ios+1 where id=".$re['id'];
        }
    }else{
        if($type == '1'){
            $sql = "insert into tttj.activity_log (android,channel) VALUES (1,$test)";
        }else{
            $sql = "insert into tttj.activity_log (ios,channel) VALUES (1,$test)";
        }
    }
    exec_db($sql);
    echo echojson('success','1',$type);exit;
}

if (version_compare($ver, '3.1.4', '>=')){
            paracheck($pt, $ver);
}

$tpl->display("{$tp}.html");
?>

